package com.example.customvidewbyheroes;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class DrawPathView extends View {


    private Paint paint;
    private Path path;
    public DrawPathView(Context context) {
        super(context);
        initView();
    }

    public DrawPathView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public DrawPathView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    public DrawPathView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView();
    }


    private void initView(){
        paint = new Paint();
        path = new Path();
        paint.setColor(Color.YELLOW);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(15);
        path.moveTo(50,50);
        path.lineTo(100,100);
        path.lineTo(100,300);
        path.lineTo(300,50);
    }


    @Override
    protected void onDraw(Canvas canvas) {

        canvas.drawPath(path,paint);
        canvas.save();
        canvas.restore();
    }
}
